import { defineConfig } from 'vitest/config'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'

export default defineConfig({
    plugins: [vue()],
    test: {
        // 启用类似 jest 的全局测试 API
        globals: true,
        // 模拟 DOM 环境
        environment: 'happy-dom',
        // 支持 tsx 组件
        transformMode: {
            web: [/.[tj]sx$/],
        },
        // 路径别名
        alias: {
            '@': resolve(__dirname, './src'),
            '@components': resolve(__dirname, './src/components'),
            '@stores': resolve(__dirname, './src/stores'),
            '@views': resolve(__dirname, './src/views'),
        },
        coverage: {
            reporter: ['text', 'json', 'html'],
            exclude: [
                'node_modules/',
                'src/types/',
                '**/*.d.ts',
                'tests/setup.ts',
                '**/*.{test,spec}.{ts,tsx}',
            ],
        },
    },
})
